﻿namespace NTLib.Core.Manipulators
{
    using NTLib.Core.Threading;

    /// <summary>
    /// Thead Safe accessor using the ReaderWriterLocker
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class RWThreadSafeAccessor<T> : ThreadSafeAccessor<T, ReaderWriterLocker>
    {
        #region Ctor

        /// <summary>
        /// Initializes a new instance of the <see cref="RWThreadSafeAccessor{T}"/> class.
        /// </summary>
        public RWThreadSafeAccessor(bool disposeContent = false)
            : base(null, disposeContent)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="RWThreadSafeAccessor{T}" /> class.
        /// </summary>
        /// <param name="locker">The locker.</param>
        /// <param name="disposeContent">if set to <c>true</c> [dispose content].</param>
        public RWThreadSafeAccessor(ReaderWriterLocker locker = null, bool disposeContent = false)
            : base(locker, disposeContent)
        {
        }

        #endregion
    }

    /// <summary>
    /// Thead Safe accessor using the ReaderWriterLocker
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class SemaphoreThreadSafeAccessor<T> : ThreadSafeAccessor<T, SemaphoreLocker>
    {
        #region Ctor

        /// <summary>
        /// Initializes a new instance of the <see cref="SemaphoreThreadSafeAccessor{T}" /> class.
        /// </summary>
        /// <param name="disposeContent">if set to <c>true</c> [dispose content].</param>
        public SemaphoreThreadSafeAccessor(bool disposeContent = false)
            : base(null, disposeContent)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="SemaphoreThreadSafeAccessor{T}" /> class.
        /// </summary>
        /// <param name="locker">The locker.</param>
        /// <param name="disposeContent">if set to <c>true</c> [dispose content].</param>
        public SemaphoreThreadSafeAccessor(SemaphoreLocker locker = null, bool disposeContent = false)
            : base(locker, disposeContent)
        {
        }

        #endregion
    }

    /// <summary>
    /// Thead Safe accessor using the ReaderWriterLocker
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class AsyncThreadSafeAccessor<T> : ThreadSafeAccessor<T, AsyncLocker>
    {
        #region Ctor

        /// <summary>
        /// Initializes a new instance of the <see cref="AsyncThreadSafeAccessor{T}" /> class.
        /// </summary>
        /// <param name="disposeContent">if set to <c>true</c> [dispose content].</param>
        public AsyncThreadSafeAccessor(bool disposeContent = false)
            : base(null, disposeContent)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="AsyncThreadSafeAccessor{T}" /> class.
        /// </summary>
        /// <param name="locker">The locker.</param>
        /// <param name="disposeContent">if set to <c>true</c> [dispose content].</param>
        public AsyncThreadSafeAccessor(AsyncLocker locker = null, bool disposeContent = false)
            : base(locker, disposeContent)
        {
        }

        #endregion
    }
}
